/*
* OnceFanCalculatorService.java
* Created on  2015/8/5 11:53
* 版本       修改时间          作者      修改内容
* V1.0.1    2015/8/5       xfz    初始版本
*
*/

package com.infitecs.eyas.oncefan.service;

import com.infitecs.eyas.oncefan.dao.OnceFanCalculatorBaseDao;
import com.infitecs.eyas.oncefan.dao.OnceFanCalculatorDao;
import com.infitecs.eyas.oncefan.model.OnceFanBaseCal;
import com.infitecs.eyas.oncefan.model.OnceFanCalculator;
import com.infitecs.eyas.session.SessionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 类的描述信息
 *
 * @author xfz
 * @version 1.0.1
 */
@Service
public class OnceFanCalculatorService {

    @Autowired
    private SessionService sessionService;

    @Autowired
    private OnceFanCalculatorDao onceFanCalculatorDao;

    @Autowired
    private OnceFanCalculatorBaseDao onceFanCalculatorBaseDao;

    public void insertOnceFanCalculator(){
        int caseId = sessionService.getCaseId();
        OnceFanCalculator onceFanCalculator = new OnceFanCalculator();
        onceFanCalculator.setCaseId(caseId);
        onceFanCalculator.setClassA("btn green addable");
        onceFanCalculator.setClassI("fa fa-plus");
        for (int i = 1;i<=7;i++){
            onceFanCalculator.setLagreType(1);
            switch (i) {
                case 1:
                    onceFanCalculator.setSmallType(i);
                    onceFanCalculator.setTitle("管段1");
                    onceFanCalculatorDao.insertOnceFanCalculator(onceFanCalculator);
                    break;
                case 2:
                    onceFanCalculator.setSmallType(i);
                    onceFanCalculator.setTitle("零件1");
                    onceFanCalculatorDao.insertOnceFanCalculator(onceFanCalculator);
                    break;
                case 3:
                    onceFanCalculator.setSmallType(i);
                    onceFanCalculator.setTitle("部件1");
                    onceFanCalculatorDao.insertOnceFanCalculator(onceFanCalculator);
                    break;
                case 4:
                    onceFanCalculator.setSmallType(i);
                    onceFanCalculator.setTitle("设备1");
                    onceFanCalculatorDao.insertOnceFanCalculator(onceFanCalculator);
                    break;
                case 5:
                    onceFanCalculator.setSmallType(i);
                    onceFanCalculator.setTitle("提升压头损失");
                    onceFanCalculatorDao.insertOnceFanCalculator(onceFanCalculator);
                    break;
                case 6:
                    onceFanCalculator.setSmallType(i);
                    onceFanCalculator.setTitle("加速损失");
                    onceFanCalculatorDao.insertOnceFanCalculator(onceFanCalculator);
                    break;
                case 7:
                    onceFanCalculator.setSmallType(i);
                    onceFanCalculator.setTitle("自生通风");
                    onceFanCalculatorDao.insertOnceFanCalculator(onceFanCalculator);
                    break;
            }

        }
        for (int i = 1;i<=7;i++){
            onceFanCalculator.setLagreType(2);
            switch (i) {
                case 1:
                    onceFanCalculator.setSmallType(i);
                    onceFanCalculator.setTitle("管段1");
                    onceFanCalculatorDao.insertOnceFanCalculator(onceFanCalculator);
                    break;
                case 2:
                    onceFanCalculator.setSmallType(i);
                    onceFanCalculator.setTitle("零件1");
                    onceFanCalculatorDao.insertOnceFanCalculator(onceFanCalculator);
                    break;
                case 3:
                    onceFanCalculator.setSmallType(i);
                    onceFanCalculator.setTitle("部件1");
                    onceFanCalculatorDao.insertOnceFanCalculator(onceFanCalculator);
                    break;
                case 4:
                    onceFanCalculator.setSmallType(i);
                    onceFanCalculator.setTitle("设备1");
                    onceFanCalculatorDao.insertOnceFanCalculator(onceFanCalculator);
                    break;
                case 5:
                    onceFanCalculator.setSmallType(i);
                    onceFanCalculator.setTitle("提升压头损失");
                    onceFanCalculatorDao.insertOnceFanCalculator(onceFanCalculator);
                    break;
                case 6:
                    onceFanCalculator.setSmallType(i);
                    onceFanCalculator.setTitle("加速损失");
                    onceFanCalculatorDao.insertOnceFanCalculator(onceFanCalculator);
                    break;
                case 7:
                    onceFanCalculator.setSmallType(i);
                    onceFanCalculator.setTitle("自生通风");
                    onceFanCalculatorDao.insertOnceFanCalculator(onceFanCalculator);
                    break;
            }

        }
    }

    public List<OnceFanCalculator> getOnceFanCalculatorList(){
        List<OnceFanCalculator> onceFanCalculators =onceFanCalculatorDao.getOnceFanCalculator(sessionService.getCaseId());
        return onceFanCalculators;
    }

    public List<OnceFanCalculator> getIn(){
        return onceFanCalculatorDao.getIn(sessionService.getCaseId());
    }

    public List<OnceFanCalculator> getOut(){
        return onceFanCalculatorDao.getOut(sessionService.getCaseId());
    }

    public int insertOneOnceFan(OnceFanCalculator onceFanCalculator){
        onceFanCalculator.setCaseId(sessionService.getCaseId());
        onceFanCalculatorDao.insertOnceFanCalculator(onceFanCalculator);
        return onceFanCalculator.getId();
    }

    public void del(int id){
        onceFanCalculatorDao.del(id);
    }

    public void editTitle(OnceFanCalculator onceFanCalculator){
        onceFanCalculatorDao.editTitle(onceFanCalculator);
    }

    public void update(OnceFanCalculator onceFanCalculator){
        onceFanCalculatorDao.update(onceFanCalculator);
    }

    public OnceFanBaseCal getOnceFanBaseCal(){
        return onceFanCalculatorBaseDao.getOnceFanCalaulatorBaseByCaseId(sessionService.getCaseId());
    }

    public void insertNewOnceFanBase() {
        onceFanCalculatorBaseDao.insertNew(sessionService.getCaseId());
    }

    public void updateParam(OnceFanBaseCal onceFanBaseCal) {
        onceFanCalculatorBaseDao.updateParam(onceFanBaseCal);
    }

}
